package ink.lovejinhu.leetcode;

import ink.lovejinhu.common.Node;

/**
 * @author jinhu
 * created 2021-07-23 17:30
 */
public class Solution_0559 {
    public int maxDepth(Node root) {
        return dfs(root);
    }

    public int dfs(Node root) {
        if (root == null) return 0;
        if (root.children == null) return 1;
        int max = 0;
        for (int i = 0; i < root.children.size(); i++) {
            if (max < dfs(root.children.get(i))) {
                max = dfs(root.children.get(i));
            }
        }
        return max + 1;
    }
}
